from time import*
a=open('m1_sorted.txt').readlines()
b=open('m2_reverse.txt').readlines()
c=open('m3_shuffle.txt').readlines()

mas1=list()
for x in range(len(a)):
    mas1.append(int(a[x]))

mas2=list()
for z in range(len(b)):
    mas2.append(int(b[z]))

mas3=list()
for y in range(len(c)):
    mas3.append(int(c[y]))



time1_1=time()
for i in range(len(mas1)):
    v=0
    for j in range(len(mas1)-i-1):
        if mas1[j] > mas1[j+1] :
            mas1[j], mas1[j+1] = mas1[j+1], mas1[j]
            v += 1
    if v==0:
        break
time1_2=time()
time11=time1_2 - time1_1
time1=time11*1000

time2_1=time()
for i in range(len(mas2)):
    v=0
    for j in range(len(mas2)-i-1):
        if mas2[j] > mas2[j+1] :
            mas2[j], mas2[j+1] = mas2[j+1], mas2[j]
            v += 1
    if v==0:
        break
time2_2=time()
time22=time2_2 - time2_1
time2=time22 * 1000

time3_1=time()
for i in range(len(mas3)):
    v=0
    for j in range(len(mas3)-i-1):
        if mas3[j] > mas3[j+1] :
            mas3[j], mas3[j+1] = mas3[j+1], mas3[j]
            v += 1
    if v==0:
        break
time3_2=time()
time33=time3_2 - time3_1
time3=time33 * 1000


print('m1_sorted', int(time1) ,'milliseconds')
print('m2_reverse', int(time2) ,'milliseconds')
print('m3_shuffle', int(time3) ,'milliseconds')
